package me.Adventure;

import java.util.ArrayList;

import me.enums.ItemType;
import me.model.AdventureItem;
import me.model.Spear;

public class ItemPosition {

	private static ItemPosition instance = null;
	private ArrayList<AdventureItem> entities;

	public static ItemPosition getInstance(){
		if(instance == null){
			instance = new ItemPosition();
		}

		return instance;
	}

	private ItemPosition() {
		placeAdventureItem();
	}

	public void placeAdventureItem(){
		setEntities(new ArrayList<AdventureItem>());
		getEntities().add(new Spear(ItemType.SPEAR, 400,400, 1));
	}

	public AdventureItem getItemAt(int index){
		return getEntities().get(index);
	}

	public int countItems(){
		return getEntities().size();
	}

	public void setEntities(ArrayList<AdventureItem> entities) {
		this.entities = entities;
	}

	public ArrayList<AdventureItem> getEntities() {
		return entities;
	}

	public void moveItem(ItemType type, int x, int y){
		AdventureItem item = getItemByType(type);
	}

	private AdventureItem getItemByType(ItemType type){

		AdventureItem item = null;

		for(AdventureItem ai:entities){
			if(ai.getType()==type){
				item = ai;
				break;
			}
		}
		return item;
	}
}